package com.intellagric.controller.module.sys_role;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.SysRoleMenuKey;
import com.intellagric.service.module.sys_role.RoleMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/10/13
 * @DESC： 角色-菜单信息管理接口
 */
@Controller
public class RoleMenuController {

    @Autowired
    private RoleMenuService roleMenuService;

    /**
     * 添加角色-权限信息
     * @Param SysRole
     * @return ResponseMessage
     */
    @RequestMapping("/role-menu/add")
    @ResponseBody
    public ResponseMessage add(SysRoleMenuKey sysRoleMenuKey) {
        return roleMenuService.addRoleMenu(sysRoleMenuKey);
    }


    /**
     * 删除角色-权限信息
     * @Param roleId
     * @return ResponseMessage
     */
    @RequestMapping("/role-menu/delete")
    @ResponseBody
    public ResponseMessage delete(String roleId) {
        return roleMenuService.deleteRoleMenuByRoleId(roleId);
    }

    /**
     * 修改角色-权限信息
     * @Param SysRole
     * @return ResponseMessage
     */
    @RequestMapping("/role-menu/edit")
    @ResponseBody
    public ResponseMessage edit(SysRoleMenuKey sysRoleMenuKey) {
        return roleMenuService.editRoleMenu(sysRoleMenuKey);
    }

    /**
     * 查询角色-权限信息列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/role-menu/list")
    @ResponseBody
    public LayuiDataGridResult getList(String roleId) {
        return roleMenuService.getRoleMenuByRoleId(roleId);
    }

}
